package practice

object SeqPractice {
  def apply(): Unit = {
    val exList = List(1, 5, 7, 100)

    def add(a: Int, b: Int): Int = a + b
    val sum = exList.reduce(add)

    val anon_sum = exList.reduce(_ + _)

    def avg(a: Int, b: Double): Double = (a + b) / 2
    val ma2 = exList.scanRight(0.0)(avg)

    assert(add(88, 88) == 176)
    assert(sum == 113)

    assert(anon_sum == 113)

    assert(avg(100, 100.0) == 100.0)
    assert(ma2 == List(8.875, 16.75, 28.5, 50.0, 0.0))

    println("All passed!")
  }
}
